package com.uuah.server.manager.service.interceptor;

import org.apache.commons.lang.StringUtils;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
import com.uuah.server.manager.common.Constants;

public class AuthInterceptor extends MethodFilterInterceptor {

	@Override
	protected String doIntercept(ActionInvocation invocation) throws Exception {
		String currentLoginUser = (String) invocation.getInvocationContext()
				.getSession().get(Constants.CURRENT_LOGIN_USER);
		if (StringUtils.isBlank(currentLoginUser)) {
			return "login";
		} else {
			String result = invocation.invoke();
			return result;
		}
	}

}
